﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using TendEase.DataAccess;
using Microsoft.Extensions.Configuration;

namespace TeBigCoreApi.Common
{
    public static class DbCommon
    {
        public static IConfiguration Config { get; set; }

        static DataAccessConfig gpsConnConfig = null;

        public static DataAccessConfig GpsConnConfig
        {
            get
            {
                if (gpsConnConfig == null)
                {
                    var provider = TendEase.DataAccess.Oracle.DataProvider.Default;

                    gpsConnConfig = new DataAccessConfig
                    {
                        Provider = provider,
                        ConnectionString = provider.GetConnectionString(
                             Config["GPS:Host"],
                             Config["GPS:Port"],
                             Config["GPS:Name"],
                             Config["GPS:User"],
                             Config["GPS:Pass"]
                        )
                    };
                }


                return gpsConnConfig;
            }
        }

        static DataAccessConfig dsConnConfig = null;
        public static DataAccessConfig DsConnConfig
        {
            get {
                if (dsConnConfig == null)
                {
                    var provider = TendEase.DataAccess.Oracle.DataProvider.Default;

                    dsConnConfig = new DataAccessConfig
                    {
                        Provider = provider,
                        ConnectionString = provider.GetConnectionString(
                             Config["DSDB:Host"],
                             Config["DSDB:Port"],
                             Config["DSDB:Name"],
                             Config["DSDB:User"],
                             Config["DSDB:Pass"]
                        )
                    };
                }


                return dsConnConfig;
            }
        }

    }
}
